<template>
    <div  id="xl">
        <!--表头结束-->
        <!--table开始-->

        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/s' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>护士工作站</el-breadcrumb-item>
            <el-breadcrumb-item>门诊医嘱执行</el-breadcrumb-item>
        </el-breadcrumb>


        <el-card>
            <!--表头-->
            <el-row>
                <el-col :span="4">
                    <el-input placeholder="请输入审批单号" v-model="eaaOrderNumber"  ></el-input>
                </el-col>

                <el-button  icon="el-icon-search" type="primary" @click="initData2(currPage,pageSize,eaaOrderNumber)"></el-button>
                <!--打印导入导出-->

            </el-row>
            <el-table

                    stripe
                    style="width: 100%"
                    :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
            >
                <el-table-column
                        prop="clincPrnNumber"
                        label="门诊医嘱执行号">
                </el-table-column>
                <el-table-column
                        prop="prescription.registration.registrationNumber"
                        label="门诊号">
                </el-table-column>
                <el-table-column
                        prop="prescriptionId"
                        label="处方号">
                </el-table-column>
                <el-table-column
                        prop="prescription.registration.patient.patientDataName"
                        label="病人姓名">
                </el-table-column>
                <el-table-column
                        prop="clincPrnAttention"
                        label="注意事项">
                </el-table-column>
                <el-table-column
                        prop="clincPrnStaff"
                        label="状态">
                  <template #default="scope">
                    <template v-if="scope.row.clincPrnStaff =='0'">
                      待执行
                    </template>
                    <template v-if="scope.row.clincPrnStaff =='1'">
                      发药中
                    </template>
                    <template v-if="scope.row.clincPrnStaff =='2'">
                      已发药
                    </template>
                    <template v-if="scope.row.clincPrnStaff =='3'">
                      执行完毕
                    </template>
                    <template v-if="scope.row.clincPrnStaff =='4'">
                      执行完毕
                    </template>
                  </template>
                </el-table-column>
                <el-table-column
                        prop="clincPrnTime"
                        :formatter="dateformat"
                        label="执行日期">
                </el-table-column>
                <el-table-column  label="操作" width="130px">
                    <template  #default="scope">
                      <el-tooltip content="详情" placement="top">
                        <el-button
                            icon="el-icon-view" size="mini"
                            @click="opc(scope.row)"></el-button>
                      </el-tooltip>


                        <el-tooltip content="删除" placement="top">
                            <el-button
                                    icon="el-icon-delete" size="mini"
                                    @click=""></el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
            </el-table>
            <br>
            <!--分页-->
            <div class="fy_div">
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="currentPage"
                        :page-sizes="[5, 10, 20, 40]"
                        :page-size="pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="tableData.length">
                </el-pagination>
            </div>

        </el-card>
        <el-dialog
                title="新增门诊医嘱"
                v-model="dialogVisible"
                width="60%"
                :before-close="handleClose">
            <el-form :model="ruleForm" status-icon  ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-row>
                    <el-col :span="10">
                        <el-form-item label="医嘱执行号" prop="eName">
                            <el-input v-model="ruleForm.eName"></el-input>

                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item label="门诊号" prop="eSex">
                            <el-input v-model="ruleForm.eSex"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item label="挂号状态" prop="eSex">
                            <el-input v-model="ruleForm.eSex"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-table
                            :data="tableData"
                            style="width: 100%">
                        <el-table-column
                                prop="date"
                                label="处方号">
                        </el-table-column>
                        <el-table-column
                                prop="name"
                                label="医嘱类型">
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="医嘱状态">
                        </el-table-column>
                        <el-table-column
                                prop="name"
                                label="处方日期">
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="执行次数">
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="最新医嘱执行号">
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="最新执行日期">
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="最新执行时间">
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="最新执行检况">
                        </el-table-column>
                    </el-table>
                </el-row>
                <el-row>

                </el-row>
            </el-form>

            <template #footer>
    <span class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
    </span>
            </template>
        </el-dialog>



    </div>
</template>

<script>
    import qs from "qs";
    import {service} from "../../http/request";
    import moment from "moment";
    export default {
        name: "opcExecuteManager",
        components: {},
        data() {
            return {
                tableData:[],
                dialogVisible: false,
                currentPage:1, //初始页
                pageSize:10,    //    每页的数据

            }
        },
        methods:{
          dateformat(row , column){
            const data = row[column.property]
            if (data == undefined){
              return
            }
            return moment(data).format("yyyy-MM-DD HH:mm:ss")
          },
            initData(){
                service("http://localhost:8088/find_clinc")
                    .then((v) => {
                        this.tableData = v.data;
                        console.log(v.data)
                    })
            },
          opc(s){
            this.$router.push({path: '/opcExecuteDetailsManager',query:{ id:s.clincPrnNumber}});
          },

            // 初始页currentPage、初始每页数据数pagesize和数据data
            handleSizeChange: function (size) {
                this.pageSize = size;
                console.log(this.pageSize)  //每页下拉显示数据
            },
            handleCurrentChange: function(currentPage){
                this.currentPage = currentPage;
                console.log(this.currentPage)  //点击第几页
            },

            ClearFrom(){
                this.ruleForm='';
                this.dialogVisible=false;
            },

            pageChange(p) {
                this.initData(p, this.pageSize)
            },
            handleClose(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {});
            }
        },
        created() {
            this.initData();

        },
    }
</script>

<style scoped>
    a {
        text-decoration: none;
    }
    .router-link-active {
        text-decoration: none;
    }

    .el-card{
        margin-top: 50px;

    }
    .block{
        margin-left: 350px;
    }
    .fy_div{
        margin-top:20px;
        margin-left: 450px;
    }
</style>